package main

import (
	"gitee.com/hlwqds/rabitmqTest/config"
	"gitee.com/hlwqds/rabitmqTest/log"
	"github.com/streadway/amqp"
)


func main(){
	url := config.GenURLFromConfig()
	conn, err := amqp.Dial(url)
	defer conn.Close()
	log.FailOnError(err, "amqp.Dial error")

	ch, err := conn.Channel()
	defer ch.Close()

	err = ch.ExchangeDeclare(
		"logs-exchange",
		"topic",
		false,
		true,
		false,
		false,
		nil,
		)
	_, err = ch.QueueDeclare(
		"msg-inbox-errors",
		false,
		true,
		false,
		false,
		nil,
		)
	_, err = ch.QueueDeclare(
		"msg-inbox-logs",
		false,
		true,
		false,
		false,
		nil,
	)
	_, err = ch.QueueDeclare(
		"all-errors",
		false,
		true,
		false,
		false,
		nil,
	)

	_ = ch.QueueBind(
		"msg-inbox-errors",
		"errors.msg-inbox",
		"logs-exchange",
		false,
		nil,
		)
	_ = ch.QueueBind(
		"msg-inbox-logs",
		"*.msg-inbox",
		"logs-exchange",
		false,
		nil,
	)

}
